<template>
  <div>
    <criteria-paged :model="model"  v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:criteria>
        <div novalidate class="form-horizontal" partial>

          <div class="form-group">
           <label for="f_plan_name" class="col-sm-2 control-lable">计划名称：</label>
           <div class="col-sm-4">
             <input type="text" class="form-control" v-model="model.f_plan_name" id="f_plan_name"
             condition="f_plan_name like '{}%'">
           </div>
           <label for="f_issued" class="col-sm-2 control-lable">是否下发：</label>
             <div class="col-sm-4">
             <v-select :value.sync="model.f_issued"
                 :options='$parent.$parent.op_issued' placeholder='请选择'
                 close-on-select clear-button
                 v-model="model.f_issued" condition="f_issued='{}'"></v-select>
               </div>
          </div>

          <div class="form-group">
            <label for="f_plan_year" class="col-sm-2 control-lable">计划年份:</label>
            <div class="col-sm-4">
              <v-select id="c_plan_year" :value.sync="model.f_plan_year"
              :options='$parent.$parent.c_year_list' close-on-select clear-button
              v-model="model.f_plan_year" placeholder='请选择年份'
              condition="f_plan_year={}"></v-select>
            </div>

            <label for="f_plan_month" class="col-sm-2 control-lable">计划月份:</label>
            <div class="col-sm-4">
              <v-select id="c_plan_month" :value.sync="model.f_plan_month" placeholder='请选择月份'
              :options='$parent.$parent.c_month_list' close-on-select clear-button
              v-model="model.f_plan_month" condition="f_plan_month='{}'"></v-select>
            </div>
          </div>
          <label for="chosenOrg" class="col-sm-2 control-lable">安检员：</label>
          <chooser :userid.sync='$parent.$parent.loginer.id' resource-type="user" :width='300' :select-data.sync='$parent.$parent.model.chosenOrg'></chooser>
          <button type="button" class="btn btn-success width-80" @click="search()">
             <span class="glyphicon glyphicon-search"></span> 查询
          </button>
        </div>
      </criteria>

      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th>计划名称</th>
            <th>是否下发</th>
            <th>计划年月</th>
            <th>安检员</th>
          </tr>
        </template>
        <template partial='body'>
          <td>{{row.f_plan_name}}</td>
          <td>{{row.f_issued}}</td>
          <td>{{row.f_plan_year}}-{{row.f_plan_month}}</td>
          <td>{{row.f_checker}}</td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
import { PagedList } from 'vue-client'
import Vue from 'vue'
import * as Util from '../Util'

export default {
  title: '预约计划下发',
  data () {
    let options = []
    let year = (new Date()).getFullYear()
    for(let i = year - 8; i <= year +1; i++ )
      options.push({label: i+'', value: i+''})
    let moptions = []
    for(let i=1; i<=12; i++)
      moptions.push({label: i + '', value: i + ''})
    let model = new PagedList('rs/sql/预约计划下发', 20, { items: '"*"', tablename: '"t_check_plan"', groupitem: '""',
    orderitem: '"f_plan_month"', f_checker:'this.chosenOrg.name', f_checker_id: 'this.chosenOrg.id', f_subcompany: 'this.f_subcompany' })
    model.f_subcompany = Vue.f_subcompany
    model.chosenOrg = {id:0, name: ''}
    return {
      c_year_list: options,
      c_month_list: moptions,
      model: model,
      loginer: Util.f,
      op_issued: [
        {label: '是', value: '是'},
        {label: '否', value: '否'}
      ]
    }
  },
  computed: {
    selected () {
      return this.$refs.paged.$refs.grid.selected
    }
  }
}
</script>
